package com.logistics.product.entity.model;

import com.logistics.erp.entity.domain.ErpLackMaterial;
import com.logistics.pick.entity.model.PickDetailRow;
import com.logistics.utils.tool.StringUtils;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;

/**
 * <p>
 * 拣配明细
 * </p>
 *
 * @author zhiyu.fan
 * @since 2024-06-27
 */
@Data
public class PickOrderDetailRow implements Serializable {

      /**
       * 物料编码
       */
      private String itemCode;

      /**
       * 物料名称
       */
      private String itemName;

      /**
       * 数量
       */
      private BigDecimal itemQty;

      /**
       * 状态
       */
      private String status;

      /**
       * 托盘
       */
      private String container;

      // 类型
      private String type;

      private String erpInvBillCode;

      public PickOrderDetailRow() {}

      public static PickOrderDetailRow build(PickDetailRow pickDetailRow, Integer status, String type){
          PickOrderDetailRow pickOrderDetailRow = new PickOrderDetailRow();
          pickOrderDetailRow.setItemCode(pickDetailRow.getItemCode());
          pickOrderDetailRow.setItemName(pickDetailRow.getItemName());
          pickOrderDetailRow.setItemQty(pickDetailRow.getItemQty());
          pickOrderDetailRow.setStatus(StringUtils.isNotNull(status) ? status.toString() : null);
          pickOrderDetailRow.setContainer(pickDetailRow.getContainer());
          pickOrderDetailRow.setType(type);
          pickOrderDetailRow.setErpInvBillCode(pickDetailRow.getErpInvBillCode());
          return pickOrderDetailRow;
      }

      public static PickOrderDetailRow build(ErpLackMaterial erpLackMaterial,String type){
          PickOrderDetailRow pickOrderDetailRow = new PickOrderDetailRow();
          pickOrderDetailRow.setItemCode(erpLackMaterial.getChildCode());
          pickOrderDetailRow.setItemQty(erpLackMaterial.getLackQty());
          pickOrderDetailRow.setItemName(erpLackMaterial.getChildName());
          pickOrderDetailRow.setType(type);
          return pickOrderDetailRow;
      }
}
